import { BaseError } from './base.error';
import { Code } from 'typeorm';

export const Response = (params) => {
  return {
    code: 200,
    message: params.message,
    data: params.data,
    count: params.count || 0,
  };
};

export interface ResponseParam {
  count?: number;
  message: string;
  data: any;
}
export const UserError = {
  //登入失效
  TOKEN_ERROR: new BaseError(20001, '登录信息以及失效,请重新登入'),

  USER_PASSWORD_ERROR: new BaseError(20002, '账户或密码错误'),

  USER_SHORT_ERROR: new BaseError(20003, '验证码错误'),

  USER_USERINFO_ERROR: new BaseError(20004, '账户不存在'),

  USER_JINGAO_OTHER_ERROR: new BaseError(
    20005,
    '警告!,不能修改他人数据,请立即停止违法行为',
  ),

  USER_NEW_PWD_ERR: new BaseError(20006, '原密码错误，修改失败'),

  USER_PHONE_ERROR: new BaseError(20007, '账户已存在'),

  USER_PHONE_HAVE_ERROR: new BaseError(20008, '账户已过审，请直接登入'),

  EXAMINE_ERROR: new BaseError(20009, '审核失败'),
};

export const CurrentError = {
  LACK_GET_SUCCESS: new BaseError(30001, '查询成功'),

  LACK_GET_FAIL: new BaseError(30001, '查询失败'),

  LACK_SET_SUCCESS: new BaseError(30001, '保存成功'),

  LACK_SET_FAIL: new BaseError(30001, '保存失败'),

  LACK_UPDATE_SUCCESS: new BaseError(30001, '修改成功'),

  LACK_UPDATE_FAIL: new BaseError(30001, '修改失败'),

  LACK_DEL_SUCCESS: new BaseError(30001, '删除成功'),

  LACK_DEL_FAIL: new BaseError(30001, '删除失败'),

  BIND_OLD: new BaseError(30001, '该设备已经被绑定'),

  BIND_FIAL: new BaseError(30001, '设备失败'),

  ID_ERROR: new BaseError(30001, '身份不能绑定设备'),

  ID_NOT: new BaseError(30001, '设备不存在'),

  LACK_BIND_FAIL: new BaseError(30010, '绑定失败'),

  LCAK_LOGIN_FAIL: new BaseError(30010, '登入失败请重新登入'),

  LCAK_CODE_FAIL: new BaseError(30010, '获取验证码失败'),

  LCAK_CREATE_CLERK_FAIL: new BaseError(30011, '添加店员失败'),

  LACK_PAYORDER_FAIL: new BaseError(40001, '下单失败'),

  LACK_NOUSER_FAIL: new BaseError(40001, '请先注册'),

  LACK_NOUSER_NEWFREE_FAIL: new BaseError(40010, '已领取过'),

  LACK_OPHOEE_FAIL: new BaseError(40001, '该手机号已注册'),

  LACK_IDNO_FAIL: new BaseError(40005, '请先完善身份证信息'),

  LACK_COLLECTIONREP_FAIL: new BaseError(40006, '该商品已收藏'),

  LACK_JULI_FAIL: new BaseError(40010, '该商品不属于本区域'),

  LACK_BANK_FAIL: new BaseError(40011, '请先绑定银行卡'),

  LACK_MONEY_FAIL: new BaseError(40012, '余额不足5元！'),

  LACK_RECEIVE_FAIL: new BaseError(40013, '领取失败'),

  LACK_DAYCOUPON_FAIL: new BaseError(40013, '今日已领取'),
};

export const OrderError = {
  LACK_NO_FAIL: new BaseError(50001, '核销失败'),

  LACK_PAY_FAIL: new BaseError(50001, '免费商品金额不符'),

  LACK_STOCK_PAY_FAIL: new BaseError(50001, '商品库存不足'),

  LACK_OVER_ERROR: new BaseError(50002, '订单已失效'),

  LACK_OK_ERROR: new BaseError(50002, '订单已核销'),

  LACK_OVERFREE_ERROR: new BaseError(50005, '领取失败'),

  LACK_CANCEL_ERROR: new BaseError(50006, '该订单不能取消'),

  LACK_FABULOUSNUM_ERROR: new BaseError(50006, '点赞数目不准确'),

  LACK_FABULOU_ORDER_ERROR: new BaseError(50006, '请先核销订单'),

  LACK_APPLY_REFUND_ERROR: new BaseError(50007, '申请退款失败'),

  LACK_APPLY_REFUND_FREE: new BaseError(500011, '已使用免费商品,不可退款'),

  LACK_EXM_REFUND_ERROR: new BaseError(50008, '审核退款失败'),

  LACK_BOSS_ERROR: new BaseError(50010, '不是来自本商家的订单'),

  LACK_NEW_GOODS_FAIL: new BaseError(50020, '不是免费产品'),

  LACK_CONFIRMCODE_PAY_FAIL: new BaseError(50021, '购买失败，请重试'),
};
